package com.zyh.flink.day02.transform;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class UnionTest {
    public static void main(String[] args) throws Exception{
        StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<String> dataStream1 = environment.socketTextStream("hadoop10", 9991);
        DataStreamSource<String> dataStream2 = environment.socketTextStream("hadoop10", 9992);
        DataStream<String> dataStream3 = dataStream1.union(dataStream2);

        //要求: union的多个流及流上的元素类型必须相同
        dataStream3.print();

        environment.execute("UnionJob");
    }
}
